<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <title>消息中心</title>
    <link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/base.css?v=14" />
    <link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/mod.css?v=14" />
    <link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/run.css?v=130" />
    <script src="{$staticHost}/static/js/jquery.min.js"></script>
    <script src="{$staticHost}/static/js/js.js"></script>
</head>
<body class="bg_gray_light">

    <section id="empty" class="empty-box">
      <div>
        <img src="{$staticHost}/static/images/bg/image1_03-min.png" >
        <p>亲，尚无消息~</p>
      </div>
    </section>

    <ul id="news_list" class="pao-news"></ul>
</body>
<script id="news_list_tpl" type="text/html">
    <%if(list.length>0){%>
    <% for(i = 0; i < list.length; i++) { %>
    <li>
      <img src="<%=list[i].objectInfo.header%>?imageView2/2/w/128"/>
      <span class="dib vm"><%=list[i].content%></span>
      <% if(list[i].descType == 'P1') { %>
      <% if(list[i].status * 1 == 5) { %>
      <a style="border-color:#ccc;color:#ccc">已同意</a>
      <% } else { %>
      <a class="agree" data-mid="<%=list[i].id%>">同意</a>
      <% } %>
      <% } %>
    </li>
    <% } %>
    <% } %>
    
</script>
<script type="text/javascript">
    $(function(){
        $.get('{$appHost}/paome_webIndex/getPaomeMsgList?mid=0&offset=100', renderNewsList);

        $('.agree').live('click', function() {
            var mid = $(this).attr('data-mid') * 1;
            var o = this;
            if(mid > 0) {
                $.post('{$appHost}/paome_webIndex/agreeJoin', {'mid': mid}, function(res){
                    res = JSON.parse(res);
                    if(res.error != undefined) {
                        alert(res.error.text);
                        if(res.error.id * 1 == 6026) {
                          $(o).parent().remove();
                        }
                    } else if(res.result != undefined) {
                        if(res.result.is_success * 1 == 1) {
                            $(o).removeClass('agree').attr({'style': 'border-color:#ccc;color:#ccc'}).text('已同意');
                        }
                    }
                });
            }
        });
    });

    function renderNewsList(data) {
        data = JSON.parse(data);
        if(data.result.list != undefined && data.result.list.length > 0) {
            var newsList = data.result;

            var html = template('news_list_tpl', newsList);
            $('#news_list').html(html);

        }
        if(data.result.list.length>0){
          $("#empty").hide();
        }else{
          $("#empty").show();
        }
    }


  $("#inform").click(function(){
    $(".one").show();
    $("#inform").addClass("on");
    $(".two").hide();
    $("#popularity").removeClass("on");

  })
   $("#popularity").click(function(){
    $(".two").show();
    $("#popularity").addClass("on");
    $(".one").hide();
    $("#inform").removeClass("on");

  })
</script>
{template 'show/web-footer'}
